package core;

import static org.junit.Assert.assertTrue;

import org.junit.Test;


public class ItemBarcodeTests 
{
	@Test
	public void nonNumericBarcodeTest()
	{
		String bCode = "123456789a99";
		boolean thrown = false;
		try{
			ItemBarcode barCode = new ItemBarcode(bCode);
		}
		catch(IllegalArgumentException e)
		{
			thrown = true;
		}
		assertTrue(thrown);
		
		thrown = false;
		ItemBarcode barCode = new ItemBarcode("123456789999");
		try{
			barCode.setBarCode("12b456789999");
		}
		catch(IllegalArgumentException e)
		{
			thrown = true;
		}
		assertTrue(thrown);
	}
	
	@Test
	public void lengthBarcodeTest()
	{
		String bCode = "12345678999";
		boolean thrown = false;
		try{
			Barcode ItemBarcode = new ItemBarcode(bCode);
		}
		catch(IllegalArgumentException e)
		{
			thrown = true;
		}
		assertTrue(thrown);
		
		thrown = false;
		ItemBarcode barCode = new ItemBarcode("123456789999");
		try{
			barCode.setBarCode("1234567899999");
		}
		catch(IllegalArgumentException e)
		{
			thrown = true;
		}
		assertTrue(thrown);
	}
}
